package com.smzd.ccms.domain;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.smzd.ccms.core.ViewMapper;
import com.smzd.core.domain.BaseScopeEntity;
import com.smzd.framework.annotation.ModuleGroup;

@ModuleGroup(value = "ccms/admin", moduleNames = "channelcfgs", moduleName = "channelcfg")
public class ChannelConfig extends BaseScopeEntity<Channel> {
	private static final long serialVersionUID = 813516969746724961L;
	// 系统字典
	private SysDict sysDict;
	// 模板
	private Template template;

	private ViewMapper viewMapper;

	private Channel channel;

	private Map<Integer, CompletConfig> completConfigs;

	/**
	 * 获取系统字典
	 * 
	 * @return
	 */
	public SysDict getSysDict() {
		return sysDict;
	}

	/**
	 * 设置系统字典
	 * 
	 * @param sysDict
	 */
	public void setSysDict(SysDict sysDict) {
		this.sysDict = sysDict;
	}

	// path
	private String path;

	/**
	 * 获取模板
	 * 
	 * @return
	 */
	public Template getTemplate() {
		return template;
	}

	/**
	 * 设置模板
	 * 
	 * @param template
	 */
	public void setTemplate(Template template) {
		this.template = template;
	}

	public ViewMapper getViewMapper() {
		return viewMapper;
	}

	public void setViewMapper(ViewMapper viewMapper) {
		this.viewMapper = viewMapper;
	}

	/**
	 * 获取path
	 * 
	 * @return
	 */
	public String getPath() {
		return path;
	}

	/**
	 * 设置path
	 * 
	 * @param path
	 */
	public void setPath(String path) {
		this.path = path;
	}

	public void setChannel(Channel channel) {
		this.channel = channel;
	}

	public Channel getChannel() {
		return channel;
	}

	/**
	 * 一个频道视角可能为模板安装了若干的组件，现在要凭借组件的位置ID把它的配置找出来。
	 * 
	 * @param parseInt
	 * @return
	 */
	public CompletConfig getCompletConfigBySpotid(int spotId) {
		return completConfigs.get(spotId);
	}

	public Map<Integer, CompletConfig> getCompletConfigs() {
		return completConfigs;
	}

	public void setCompletConfigs(Map<Integer, CompletConfig> completConfigs) {
		this.completConfigs = completConfigs;
	}

	public void putCompletConfig(CompletConfig completConfig) {
		if (this.completConfigs == null) {
			this.completConfigs = new HashMap<Integer, CompletConfig>();
		}
		this.completConfigs.put(completConfig.getSpotid(), completConfig);
	}

	public void putCompletConfigs(List<CompletConfig> completConfigs) {
		for (CompletConfig cc : completConfigs) {
			putCompletConfig(cc);
		}
	}
}